#ifndef AccountServer_h__
#define AccountServer_h__

#include "Common.h"

#include "JME_TcpSession.h"

#include "JME_ServerInterface.h"
#include "JME_MongoConnection.h"
#include "JME_MysqlConnection.h"

USING_NAMESPACE_JMENGINE;
USING_NAMESPACE_JMENGINE_NET;
USING_NAMESPACE_JMENGINE_GAME;
USING_NAMESPACE_JMENGINE_RPC;
USING_NAMESPACE_JMENGINE_DB;


typedef DBHelper<JME_MongoConnection> MongodbConnHelper;
typedef DBPool<JME_MongoConnection>	MongoDBPool;

static bool connectMongoDB(JME_MongoConnection* conn, const string& ip_str, const string& db_name, const string& name, const string& pwd);

typedef DBHelper<MysqlConnector> MysqlConnHelper;
typedef DBPool<MysqlConnector>	MysqlDBPool;

static bool connectMysql(MysqlConnector* conn, const string& ip, const string& userName, const string& pwd, const string& dbName, const unsigned short port);

class AccountServer : 
	public JME_ServerInterface
{
public:
	typedef boost::shared_ptr<AccountServer> AccountServerPtr;
public:
	AccountServer();
	~AccountServer();
	static AccountServer::AccountServerPtr getInstance();

	void init();

	MysqlDBPool* getMysqlDBPool();
	MongoDBPool* getMongoDBPool();
private:
	MysqlDBPool::DBPoolPtr _mysqlDBPool;
	MongoDBPool::DBPoolPtr _mongoDBPool;
};

#endif // AccountServer_h__
